<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
	<ui:composition>
		<h:panelGrid columns="3" width="10%">
				<h:outputLabel for="subject" value="#{msg.subject}" />
	     		<p:inputText id="subject" value="#{manageBean.emailTemplate.subject}" required="true"
	     			requiredMessage="#{msg.requiredSubject}" 
	     			title="#{component.valid ? '' : manageBean.getErrorMessage(component.clientId)}" size="115"
	     			maxlength="100" autoResize="false"/>
	     		<p:message id="subjectMsg" for="subject" display="icon"/>
		
				<h:outputLabel value="#{msg.emailType}"/>
	    		<p:selectOneMenu id="emailType" value="#{manageBean.emailTemplateType}">
	               <f:selectItems value="#{manageBean.templateType}" />   
	               <f:ajax render="templateOptions" />
	           </p:selectOneMenu> 
	           <p:message id="emailTypeMsg" for="emailType" display="icon"/>
		</h:panelGrid>

		<h3 style="margin-top:10px">#{msg.emailTemplate}</h3>
		<h:panelGrid columns="4" id="templateOptions" styleClass="emailTemplateContainer">
			<ui:repeat value="#{manageBean.mapToList(manageBean.getTemplateOptions())}" var="entry" >
				<div style="display:inline-block">
		        	<p:commandButton value="#{entry.value}" onclick="insertAtCursor('#{form}','template','{#{entry.key}}')" update=":#{form}:template" partialSubmit="true" styleClass="emailTemplateButton"/>
		        </div>
		    </ui:repeat>
		</h:panelGrid>
		<p:inputTextarea rows="12" style="width:99%" id="template" value="#{manageBean.emailTemplate.template}" 
			required="true" requiredMessage="#{msg.requiredTemplate}" 
			title="#{component.valid ? '' : manageBean.getErrorMessage(component.clientId)}"
			maxlength="500" autoResize="false"/>
		<p:message id="templateMsg" for="template"/>
	</ui:composition>
</h:body>
</html>